﻿using Coldairarrow.Business.BackStage.Platform;
using Coldairarrow.Entity.BackStage.Platform;
using Coldairarrow.Util;
using Coldairarrow.Util.DTO;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Coldairarrow.Api.Controllers.BackStage.Platform
{
    [Route("/BackStage/Platform/[controller]/[action]")]
    public class Base_PlatformController : BaseApiController
    {
        #region DI

        public Base_PlatformController(IBase_PlatformBusiness base_PlatformBus)
        {
            _base_PlatformBus = base_PlatformBus;
        }

        IBase_PlatformBusiness _base_PlatformBus { get; }

        #endregion

        #region 获取

        [HttpPost]
        public async Task<PageResult<Base_Platform>> GetDataList(PageInput<ConditionDTO> input)
        {
            return await _base_PlatformBus.GetDataListAsync(input);
        }

        [HttpPost]
        public async Task<Base_Platform> GetTheData(IdInputDTO input)
        {
            return await _base_PlatformBus.GetTheDataAsync(input.Id);
        }

        #endregion

        #region 提交

        [HttpPost]
        public async Task SaveData(Base_Platform data)
        {
            if (data.Id.IsNullOrEmpty())
            {
                InitEntity(data);

                await _base_PlatformBus.AddDataAsync(data);
            }
            else
            {
                await _base_PlatformBus.UpdateDataAsync(data);
            }
        }

        [HttpPost]
        public async Task DeleteData(List<string> ids)
        {
            await _base_PlatformBus.DeleteDataAsync(ids);
        }

        /// <summary>
        /// 后台——获取平台列表
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<List<SelectDTO>> GetPlatformList()
        {
            return await _base_PlatformBus.GetPlatformListAsync();
        }

        #endregion
    }
}